package com.zhang.util;

/**
 * @author zh
 * @create 2022-01-13 16:35
 */
public class AjaxResult {
    private Integer code = 20000;
    private boolean success;
    private String msg;
    private Object data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public boolean isSuccess() {
        return success;
    }

    public String getMsg() {
        return msg;
    }

    public Object getData() {
        return data;
    }

    private AjaxResult(){
        this.success = true;
    }
    private AjaxResult(Boolean success){
        this.success = success;
    }
    private AjaxResult(Object data){
        this.data = data;
    }
    public static AjaxResult me(){
        return new AjaxResult();
    }
    public static AjaxResult me(Boolean success, String msg){
        return new AjaxResult(success).setMsg(msg);
    }
    public static AjaxResult me(Object data){
        return new AjaxResult(data).setSuccess(true);
    }
    public AjaxResult setData(Object data){
        this.data = data;
        return this;
    }
    public AjaxResult setSuccess(Boolean success){
        this.success = success;
        return this;
    }
    public AjaxResult setMsg(String msg){
        this.msg = msg;
        return this;
    }
}
